#include <algorithm>
#include <cstdio>

typedef long long ll;
const int N = 1000005;
int n, q, r, c;

struct Node {
  int val, ans;
} tr[N << 2];

void exgcd(int a, int b, ll &x, ll &y) {
  if (b == 0) { return x = 1, y = 0, void(); }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}

inline void pushup(int x) {
  if (tr[x << 1].val < tr[x << 1 | 1].val) {
    tr[x].ans = tr[x << 1 | 1].ans;
  } else
    tr[x].ans = tr[x << 1].ans;
  tr[x].val = std::max(tr[x << 1].val, tr[x << 1 | 1].val);
}

void build(int x, int l, int r) {
  if (l == r) return tr[x].ans = l, void();
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
}

void modify(int x, int l, int r, int pos) {
  if (l == r) return tr[x].val++, void();
  int mid = (l + r) >> 1;
  if (pos <= mid) modify(x << 1, l, mid, pos);
  else
    modify(x << 1 | 1, mid + 1, r, pos);
  pushup(x);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("board.in", "r", stdin);
  freopen("board.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d%d", &n, &q, &r, &c);
  ll inv, y;
  exgcd(r, n, inv, y);
  inv = (inv % n + n) % n;
  int k = c * inv % n;
  build(1, 1, n);
  for (int i = 1, x, y; i <= q; ++i) {
    scanf("%d%d", &x, &y);
    modify(1, 1, n, ((y - 1ll * k * x % n) % n + n) % n + 1);
  }
  printf("0 %d", tr[1].ans - 1);
  return 0;
}